<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="公司">
              <a-input placeholder="请输入公司" v-model="queryParam.company"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="工厂">
              <a-input placeholder="请输入工厂" v-model="queryParam.site"></a-input>
            </a-form-item>
          </a-col>
          <template v-if="toggleSearchStatus">
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="车间">
                <a-input placeholder="请输入车间" v-model="queryParam.workshop"></a-input>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="产线">
                <a-input placeholder="请输入产线" v-model="queryParam.line"></a-input>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="产线描述">
                <a-input placeholder="请输入产线描述" v-model="queryParam.name"></a-input>
              </a-form-item>
            </a-col>
          </template>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'" />
              </a>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->
    <!-- table区域-begin -->
    <a-table
      ref="table"
      size="middle"
      :scroll="{x:true}"
      bordered
      rowKey="line"
      :columns="columns"
      :dataSource="dataSource"
      :pagination="ipagination"
      :loading="loading"
      class="j-table-force-nowrap"
      @change="handleTableChange">


        <span slot="action" slot-scope="text, record">
          <router-link
            tag="a" target="_blank"
            :to="{name:'QisLineScreen',query:{line:record.line}}"
            style="color: #237ae4"
            class="el-icon-magic-stick"
          >看板</router-link>
        </span>

    </a-table>
  </a-card>
</template>

<script>

import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { getAction } from '@api/manage'

export default {
  name: 'Qis_Board',
  mixins: [JeecgListMixin, mixinDevice],

  data() {
    return {
      description: '产线主数据管理页面',
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function(t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '公司',
          align: 'center',
          dataIndex: 'company'
        },
        {
          title: '工厂',
          align: 'center',
          dataIndex: 'site'
        },
        {
          title: '车间',
          align: 'center',
          dataIndex: 'workshop'
        },
        {
          title: '产线',
          align: 'center',
          dataIndex: 'line'
        },
        {
          title: '产线描述',
          align: 'center',
          dataIndex: 'name'
        },
        {
          title: '状态',
          align: 'center',
          dataIndex: 'status_dictText'
        },
        {
          title: '更新时间',
          align: 'center',
          dataIndex: 'ctime'
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 147,
          scopedSlots: { customRender: 'action' }
        }
      ],
      url: {
        list: '/basic/mesLineCfg/list'
      },
      dictOptions: {},
      superFieldList: []
    }
  },
  created() {
    this.getSuperFieldList()
  },
  computed: {
    importExcelUrl: function() {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    }
  },
  methods: {
    initDictConfig() {
    },
    goLineBroad(record) {
      console.log('跳转看板')
      console.log(record)
      this.$router.push({ path: './QisLineScreen', query: { line: record.line } })
    },
    exportXlsTemplate() {
      getAction(this.url.exportXlsTemplate, null).then((res) => {
      }).finally(() => {
      })
    },
    getSuperFieldList() {
      let fieldList = []
      fieldList.push({ type: 'string', value: 'company', text: '公司', dictCode: '' })
      fieldList.push({ type: 'string', value: 'site', text: '工厂', dictCode: '' })
      fieldList.push({ type: 'string', value: 'workshop', text: '车间', dictCode: '' })
      fieldList.push({ type: 'string', value: 'line', text: '产线', dictCode: '' })
      fieldList.push({ type: 'string', value: 'name', text: '产线描述', dictCode: '' })
      fieldList.push({ type: 'string', value: 'lineGroup', text: '产线所属群组', dictCode: '' })
      fieldList.push({
        type: 'BigDecimal',
        value: 'maxRunningPartno',
        text: '产线最多可以运行的工单数量',
        dictCode: ''
      })
      fieldList.push({ type: 'BigDecimal', value: 'boundarySample', text: '产线重启首样检验样品数量', dictCode: '' })
      fieldList.push({ type: 'string', value: 'status', text: '状态', dictCode: 'mes_line_cfg@STATUS' })
      fieldList.push({ type: 'date', value: 'ctime', text: '更新时间' })
      this.superFieldList = fieldList
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>
